home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / Editions.h < prev    next >
Text File  |  1991-04-17  |  13KB  |  369 lines

  1. /************************************************************
  2.  
  3. Created: Tuesday, January 29, 1991 at 6:35 PM
  4.     Editions.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.         Copyright Apple Computer, Inc.    1989-1990
  9.         All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __EDITIONS__
  15. #define __EDITIONS__
  16.  
  17. #ifndef __MEMORY__
  18. #include <Memory.h>
  19. #endif
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24.  
  25. #ifndef __FILES__
  26. #include <Files.h>
  27. #endif
  28.  
  29. #ifndef __ALIASES__
  30. #include <Aliases.h>
  31. #endif
  32.  
  33. #ifndef __DIALOGS__
  34. #include <Dialogs.h>
  35. #endif
  36.  
  37.  
  38. enum {
  39.  
  40.  
  41. /* resource types  */
  42.  
  43. #define rSectionType 'sect'                 /* ResType of saved SectionRecords */
  44.  
  45. /* section types */
  46.  
  47.     stSubscriber = 0x01,
  48.     stPublisher = 0x0A,
  49.  
  50.     sumAutomatic = 0,                       /* subscriber update mode - Automatically     */
  51.     sumManual = 1,                          /* subscriber update mode - Manually */
  52.     pumOnSave = 0,                          /* publisher update mode - OnSave            */
  53.     pumManual = 1,                          /* publisher update mode - Manually */
  54.  
  55.     kPartsNotUsed = 0,
  56.     kPartNumberUnknown = -1,                /* misc */
  57.  
  58.     kPreviewWidth = 120,
  59.     kPreviewHeight = 120,
  60.  
  61.  
  62. #define kPublisherDocAliasFormat 'alis'
  63. #define kPreviewFormat 'prvw'
  64. #define kFormatListFormat 'fmts'
  65.  
  66. /* bits for formatsMask */
  67.  
  68.     kPICTformatMask = 1,
  69.     kTEXTformatMask = 2,
  70.     ksndFormatMask = 4,
  71.  
  72. /* Finder types for edition files */
  73.  
  74. #define kPICTEditionFileType 'edtp'
  75. #define kTEXTEditionFileType 'edtt'
  76. #define ksndEditionFileType 'edts'
  77. #define kUnknownEditionFileType 'edtu'
  78.  
  79. /* pseudo-item hits for dialogHooks 
  80.  the first if for NewPublisher or NewSubscriber Dialogs */
  81.  
  82.     emHookRedrawPreview = 150,
  83.  
  84. /* the following are for SectionOptions Dialog */
  85.     emHookCancelSection = 160,
  86.     emHookGoToPublisher = 161,
  87.     emHookGetEditionNow = 162,
  88.     emHookSendEditionNow = 162,
  89.     emHookManualUpdateMode = 163,
  90.     emHookAutoUpdateMode = 164
  91. };
  92. enum {
  93.  
  94. /* the refcon field of the dialog record during a modalfilter 
  95.  or dialoghook contains one the following */
  96.  
  97. #define emOptionsDialogRefCon 'optn'
  98. #define emCancelSectionDialogRefCon 'cncl'
  99. #define emGoToPubErrDialogRefCon 'gerr'
  100.  
  101.     kFormatLengthUnknown = -1
  102. };
  103.  
  104. typedef char SectionType;                   /* one byte, stSubscriber or stPublisher */
  105. typedef unsigned long TimeStamp;            /* seconds since 1904 */
  106. typedef unsigned long FormatType;           /* similar to ResType */
  107. typedef Handle EditionRefNum;               /* used in Edition I/O */
  108. /* update modes */
  109. typedef short UpdateMode;                   /* sumAutomatic, pumSuspend, etc */
  110.  
  111. struct SectionRecord {
  112.     SignedByte version;                     /* always 0x01 in system 7.0 */
  113.     SectionType kind;                       /* stSubscriber or stPublisher */
  114.     UpdateMode mode;                        /* auto or manual */
  115.     TimeStamp mdDate;                       /* last change in document */
  116.     long sectionID;                         /* app. specific, unique per document */
  117.     long refCon;                            /* application specific */
  118.     AliasHandle alias;                      /* handle to Alias Record */
  119.     long subPart;                           /* which part of container file */
  120.     struct SectionRecord **nextSection;     /* for linked list of app's Sections */
  121.     Handle controlBlock;                    /* used internally */
  122.     EditionRefNum refNum;                   /* used internally */
  123. };
  124.  
  125. typedef struct SectionRecord SectionRecord;
  126. typedef SectionRecord *SectionPtr, **SectionHandle;
  127.  
  128. struct EditionContainerSpec {
  129.     FSSpec theFile;
  130.     ScriptCode theFileScript;
  131.     long thePart;
  132.     Str31 thePartName;
  133.     ScriptCode thePartScript;
  134. };
  135.  
  136. typedef struct EditionContainerSpec EditionContainerSpec;
  137. typedef EditionContainerSpec *EditionContainerSpecPtr;
  138.  
  139. struct EditionInfoRecord {
  140.     TimeStamp crDate;                       /* date EditionContainer was created */
  141.     TimeStamp mdDate;                       /* date of last change */
  142.     OSType fdCreator;                       /* file creator */
  143.     OSType fdType;                          /* file type */
  144.     EditionContainerSpec container;         /* the Edition */
  145. };
  146.  
  147. typedef struct EditionInfoRecord EditionInfoRecord;
  148.  
  149. struct NewPublisherReply {
  150.     Boolean canceled;                       /* O */
  151.     Boolean replacing ;
  152.     Boolean usePart;                        /* I */
  153.     Handle preview;                         /* I */
  154.     FormatType previewFormat;               /* I */
  155.     EditionContainerSpec container;         /* I/O */
  156. };
  157.  
  158. typedef struct NewPublisherReply NewPublisherReply;
  159.  
  160. struct NewSubscriberReply {
  161.     Boolean canceled;                       /* O */
  162.     unsigned char formatsMask;
  163.     EditionContainerSpec container;         /*I/O*/
  164. };
  165.  
  166. typedef struct NewSubscriberReply NewSubscriberReply;
  167.  
  168. struct SectionOptionsReply {
  169.     Boolean canceled;                       /* O */
  170.     Boolean changed;                        /* O */
  171.     SectionHandle sectionH;                 /* I */
  172.     ResType action;                         /* O */
  173. };
  174.  
  175. typedef struct SectionOptionsReply SectionOptionsReply;
  176.  
  177.  
  178. typedef pascal Boolean (*ExpModalFilterProcPtr) (DialogPtr theDialog, EventRecord *theEvent,
  179.  short itemOffset, short *itemHit, Ptr yourDataPtr);
  180. typedef pascal short (*ExpDlgHookProcPtr) (short itemOffset,
  181.   short itemHit, DialogPtr theDialog, Ptr yourDataPtr);
  182.  
  183. enum {ioHasFormat,ioReadFormat,ioNewFormat,ioWriteFormat};
  184. typedef unsigned char FormatIOVerb;
  185.  
  186.  
  187. struct FormatIOParamBlock {
  188.     long ioRefNum;
  189.     FormatType format;
  190.     long formatIndex;
  191.     unsigned long offset;
  192.     Ptr buffPtr;
  193.     unsigned long buffLen;
  194. };
  195.  
  196. typedef struct FormatIOParamBlock FormatIOParamBlock;
  197.  
  198.  
  199. typedef pascal short (*FormatIOProcPtr) (FormatIOVerb selector, FormatIOParamBlock *PB);
  200.  
  201. enum {eoOpen,eoClose,eoOpenNew,eoCloseNew,eoCanSubscribe};
  202. typedef unsigned char EditionOpenerVerb;
  203.  
  204.  
  205. struct EditionOpenerParamBlock {
  206.     EditionInfoRecord info;
  207.     SectionHandle sectionH;
  208.     FSSpecPtr document;
  209.     OSType fdCreator;
  210.     long ioRefNum;
  211.     FormatIOProcPtr ioProc;
  212.     Boolean success;
  213.     unsigned char formatsMask;
  214. };
  215.  
  216. typedef struct EditionOpenerParamBlock EditionOpenerParamBlock;
  217.  
  218.  
  219. typedef pascal short (*EditionOpenerProcPtr) (EditionOpenerVerb selector, FormatIOParamBlock *PB);
  220.  
  221.  
  222.  
  223.  
  224. /* 
  225.     Section events now arrive in the message buffer using the AppleEvent format.
  226.     The direct object parameter is an aeTemporaryIDParamType ('tid '). The temporary
  227.     ID's type is rSectionType ('sect') and the 32-bit value is a SectionHandle.
  228.     The following is a sample buffer
  229.     
  230.     name            offset    contents
  231.     ----            ------    --------
  232.     
  233.     header            0        'aevt'
  234.     majorVersion    4        0x01
  235.     minorVersion    6        0x01
  236.     endOfMetaData    8        ';;;;' 
  237.     directObjKey    12        '----' 
  238.     paramType        16        'tid ' 
  239.     paramLength        20        0x0008 
  240.     tempIDType        24        'sect' 
  241.     tempID             28        the SectionHandle <-- this is want you want*/
  242.  
  243.  
  244. #define sectionEventMsgClass 'sect'
  245. #define sectionReadMsgID 'read'
  246. #define sectionWriteMsgID 'writ'
  247. #define sectionScrollMsgID 'scrl'
  248. #define sectionCancelMsgID 'cncl'
  249.  
  250. #ifdef __cplusplus
  251. extern "C" {
  252. #endif
  253. pascal OSErr InitEditionPack(void)
  254.     = {0x3F3C,0x0011,0x303C,0x0100,0xA82D}; 
  255. pascal OSErr NewSection(const EditionContainerSpec *container,
  256.                         const FSSpec *sectionDocument,
  257.                         SectionType kind,
  258.                         long sectionID,
  259.                         UpdateMode initalMode,
  260.                         SectionHandle *sectionH)
  261.     = {0x303C,0x0A02,0xA82D}; 
  262. pascal OSErr RegisterSection(const FSSpec *sectionDocument,
  263.                              SectionHandle sectionH,
  264.                              Boolean *aliasWasUpdated)
  265.     = {0x303C,0x0604,0xA82D}; 
  266. pascal OSErr UnRegisterSection(SectionHandle sectionH)
  267.     = {0x303C,0x0206,0xA82D}; 
  268. pascal OSErr IsRegisteredSection(SectionHandle sectionH)
  269.     = {0x303C,0x0208,0xA82D}; 
  270. pascal OSErr AssociateSection(SectionHandle sectionH,
  271.                               const FSSpec *newSectionDocument)
  272.     = {0x303C,0x040C,0xA82D}; 
  273. pascal OSErr CreateEditionContainerFile(const FSSpec *editionFile,
  274.                                         OSType fdCreator,
  275.                                         ScriptCode editionFileNameScript)
  276.     = {0x303C,0x050E,0xA82D}; 
  277. pascal OSErr DeleteEditionContainerFile(const FSSpec *editionFile)
  278.     = {0x303C,0x0210,0xA82D}; 
  279. pascal OSErr OpenEdition(SectionHandle subscriberSectionH,
  280.                          EditionRefNum *refNum)
  281.     = {0x303C,0x0412,0xA82D}; 
  282. pascal OSErr OpenNewEdition(SectionHandle publisherSectionH,
  283.                             OSType fdCreator,
  284.                             const FSSpec *publisherSectionDocument,
  285.                             EditionRefNum *refNum)
  286.     = {0x303C,0x0814,0xA82D}; 
  287. pascal OSErr CloseEdition(EditionRefNum whichEdition,
  288.                           Boolean successful)
  289.     = {0x303C,0x0316,0xA82D}; 
  290. pascal OSErr EditionHasFormat(EditionRefNum whichEdition,
  291.                               FormatType whichFormat,
  292.                               Size *formatSize)
  293.     = {0x303C,0x0618,0xA82D}; 
  294. pascal OSErr ReadEdition(EditionRefNum whichEdition,
  295.                          FormatType whichFormat,
  296.                          void *buffPtr,
  297.                          Size *buffLen)
  298.     = {0x303C,0x081A,0xA82D}; 
  299. pascal OSErr WriteEdition(EditionRefNum whichEdition,
  300.                           FormatType whichFormat,
  301.                           const void *buffPtr,
  302.                           Size buffLen)
  303.     = {0x303C,0x081C,0xA82D}; 
  304. pascal OSErr GetEditionFormatMark(EditionRefNum whichEdition,
  305.                                   FormatType whichFormat,
  306.                                   unsigned long *currentMark)
  307.     = {0x303C,0x061E,0xA82D}; 
  308. pascal OSErr SetEditionFormatMark(EditionRefNum whichEdition,
  309.                                   FormatType whichFormat,
  310.                                   unsigned long setMarkTo)
  311.     = {0x303C,0x0620,0xA82D}; 
  312. pascal OSErr GetEditionInfo(const SectionHandle sectionH,
  313.                             EditionInfoRecord *editionInfo)
  314.     = {0x303C,0x0422,0xA82D}; 
  315. pascal OSErr GoToPublisherSection(const EditionContainerSpec *container)
  316.     = {0x303C,0x0224,0xA82D}; 
  317. pascal OSErr GetLastEditionContainerUsed(EditionContainerSpec *container)
  318.     = {0x303C,0x0226,0xA82D}; 
  319. pascal OSErr GetStandardFormats(const EditionContainerSpec *container,
  320.                                 FormatType *previewFormat,
  321.                                 Handle preview,
  322.                                 Handle publisherAlias,
  323.                                 Handle formats)
  324.     = {0x303C,0x0A28,0xA82D}; 
  325. pascal OSErr GetEditionOpenerProc(EditionOpenerProcPtr *opener)
  326.     = {0x303C,0x022A,0xA82D}; 
  327. pascal OSErr SetEditionOpenerProc(EditionOpenerProcPtr opener)
  328.     = {0x303C,0x022C,0xA82D}; 
  329. pascal OSErr CallEditionOpenerProc(EditionOpenerVerb selector,
  330.                                    EditionOpenerParamBlock *PB,
  331.                                    EditionOpenerProcPtr routine)
  332.     = {0x303C,0x052E,0xA82D}; 
  333. pascal OSErr CallFormatIOProc(FormatIOVerb selector,
  334.                               FormatIOParamBlock *PB,
  335.                               FormatIOProcPtr routine)
  336.     = {0x303C,0x0530,0xA82D}; 
  337. pascal OSErr NewSubscriberDialog(NewSubscriberReply *reply)
  338.     = {0x303C,0x0232,0xA82D}; 
  339. pascal OSErr NewSubscriberExpDialog(NewSubscriberReply *reply,
  340.                                     Point where,
  341.                                     short expansionDITLresID,
  342.                                     ExpDlgHookProcPtr dlgHook,
  343.                                     ExpModalFilterProcPtr filterProc,
  344.                                     void *yourDataPtr)
  345.     = {0x303C,0x0B34,0xA82D}; 
  346. pascal OSErr NewPublisherDialog(NewPublisherReply *reply)
  347.     = {0x303C,0x0236,0xA82D}; 
  348. pascal OSErr NewPublisherExpDialog(NewPublisherReply *reply,
  349.                                    Point where,
  350.                                    short expansionDITLresID,
  351.                                    ExpDlgHookProcPtr dlgHook,
  352.                                    ExpModalFilterProcPtr filterProc,
  353.                                    void *yourDataPtr)
  354.     = {0x303C,0x0B38,0xA82D}; 
  355. pascal OSErr SectionOptionsDialog(SectionOptionsReply *reply)
  356.     = {0x303C,0x023A,0xA82D}; 
  357. pascal OSErr SectionOptionsExpDialog(SectionOptionsReply *reply,
  358.                                      Point where,
  359.                                      short expansionDITLresID,
  360.                                      ExpDlgHookProcPtr dlgHook,
  361.                                      ExpModalFilterProcPtr filterProc,
  362.                                      void *yourDataPtr)
  363.     = {0x303C,0x0B3C,0xA82D}; 
  364. #ifdef __cplusplus
  365. }
  366. #endif
  367.  
  368. #endif
  369.